package com.grj.service.common.controller;

import com.grj.service.common.config.MinioTemplate;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


/**
 * @author 14505
 */
@RestController
@RequestMapping("/file")
@RequiredArgsConstructor
public class FileController {

    private final MinioTemplate minioTemplate;


    @PostMapping("/upload")
    public String upload(MultipartFile file) throws Exception {
        minioTemplate.putObject("head", file.getOriginalFilename(), file);
        return minioTemplate.getObjectUrl("head", file.getOriginalFilename());
    }

}
